package com.beimi.fight;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.beimi.util.ClassUtil;
import com.corundumstudio.socketio.SocketIOServer;

@Component
public class ServerRunner implements CommandLineRunner {
	
	private final SocketIOServer server;

	@Autowired
	public ServerRunner(SocketIOServer server) {
		this.server = server;
	}

	public void run(String... args) throws Exception {
		List<Class<?>> list = ClassUtil.getClasses("com.beimi.fight.listener");
		for (Class<?> class1 : list) {
			server.getNamespace("/bm/game").addListeners(class1.newInstance());
		}
		server.start();
	}
}
